#ifndef __APP_KEY_H
#define __APP_KEY_H

#include "main.h"
#include "dma.h"
#include "usart.h"
#include "gpio.h"
#include "app_rtthread.h"

#define KEY_DOWN 	0
#define KEY_UP 		1

#define KEY_COUNT_MIN 5
#define KEY_COUNT_MAX 80

#define KEY_LONG  2
#define KEY_SHROT 1
#define KEY_NONE  0

#define READ_KEY(GPIOx,GPIO_Pin) HAL_GPIO_ReadPin(GPIOx,GPIO_Pin)

#define INIT_KEY1 {SW1_GPIO_Port,SW1_Pin,1,0,0}
#define INIT_KEY2 {SW2_GPIO_Port,SW2_Pin,2,0,0}
#define INIT_KEY3 {SW3_GPIO_Port,SW3_Pin,3,0,0}

typedef struct app_key_info{
	GPIO_TypeDef *GPIO;
	uint16_t Pin;
	uint8_t num;
	uint8_t status;
	uint16_t count;
}KEY_INFO;

extern KEY_INFO key1;
extern KEY_INFO key2;
extern KEY_INFO key3;

void key_init(void);
void key_scan(void);
void key_action(uint8_t num,uint8_t status);

#endif
